<template>
  <div>
<!--使用组件，全局组件在main.js中引入、注册 -->
<TypeNav/>
<ListContainer/>
<TodayRecommend/>
<Rank/>
<Like/>
<!-- 渲染请求到的数据  、父组件向子组件传输数据-->
<Floor  v-for='(floor,index) in floorList' 
:key='floor.id' 
:list='floor'
/>
<Brand/>
  </div>
</template>

<script>
// 引入组件（非全局）
import ListContainer from '@/views/Home/ListContainer'
import TodayRecommend from '@/views/Home/TodayRecommend'
 import  Rank from '@/views/Home/Rank'
 import Like from '@/views/Home/Like'
 import Floor from '@/views/Home/Floor'
 import Brand from '@/views/Home/Brand'

 import {mapState} from 'vuex'

  export default {
    name:'',
  //注册组件（非全局）
    components:{
      ListContainer,
      TodayRecommend,
      Rank,
      Like,
      Floor,
      Brand
    },
    
//编译好的HTML挂载到页面完成后执行的钩子，(执行ajax获取数据请求进行数据初始化)

mounted(){
  //派发action,获取floor组件的数据
  this.$store.dispatch('getFloorList')
  // 派发action,获取用户登录后的用户信息在首页展示
  // this.$store.dispatch('getUserInfo')

}, 
computed:{
  //组件中调用请求获得(action)的公共数据 
  ...mapState({
floorList:state=>state.home.floorList
  })
}

  }
</script>

<style lang="scss" scoped>

</style>